#include "stdio.h"
#include "unistd.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "fcntl.h"
#include "stdlib.h"
#include "string.h"


#define BEEP_ON   1
#define BEEP_OFF  0


int main(int argc, char *argv[])
{
    int fd;
    int ret;
    char *filename ;
    unsigned char data[1];
    if(argc != 3)
    {
        printf("Usage: %s <filename> <data>\n", argv[0]);
        return -1;
    }
    filename = argv[1];
    fd = open(filename, O_RDWR);
    if(fd < 0)
    {
        printf("open %s faiBEEP\n", filename);
        return -1;
    }
    data[0] = atoi(argv[2]);
    ret = write(fd, data, 1);
    if(ret < 0)
    {
        printf("write %s faiBEEP\n", filename);
        return -1;
    }
    
    close(fd);
    return 0;

}